package com.hzqy.web.ac.industry;

import com.alibaba.fastjson.JSONObject;
import com.hzqy.commons.utils.YhzHttpUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;


@Controller
@RequestMapping("/")
public class yhzAction {
    protected final Logger LOG = LoggerFactory.getLogger(getClass());

    /**
     * 获取用户信息
     * @param itv_id
     * @return
     */
    @RequestMapping("/industry/yhUser")
    @ResponseBody
    public JSONObject selectUserInfo(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/userinfo?itv_id="+itv_id,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 送餐服务
     * @param itv_id
     * @return
     */

    @RequestMapping("/industry/RoomServivce")
    @ResponseBody
    public JSONObject getRoomServivce(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/apply/meals?itv_id="+itv_id,itv_id,"POST");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 今日菜品
     * @param itv_id
     * @return
     */

    @RequestMapping("/industry/todayFood")
    @ResponseBody
    public JSONObject selectTodayFood(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/day/food?itv_id="+itv_id,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 预约送餐
     * @param itv_id
     * @return
     */

    @RequestMapping("/industry/bookingFood")
    @ResponseBody
    public JSONObject getbookingFood(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/booking/food?itv_id="+itv_id,itv_id,"POST");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 昨日菜品
     * @param itv_id
     * @return
     */
    @RequestMapping("/industry/yesterdayFood")
    @ResponseBody
    public JSONObject selectyesterdayFood(String itv_id,int time){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/yesterday/food?itv_id="+itv_id+"&time="+time,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 菜品点赞
     * @param itv_id
     * @return
     */

    @RequestMapping("/industry/foodLike")
    @ResponseBody
    public JSONObject getFoodLike(String itv_id,String food_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/give/like?itv_id="+itv_id+"&food_id="+food_id,itv_id,"POST");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 喜报平安
     * @param itv_id
     * @return
     */
    @RequestMapping("/industry/checkSafty")
    @ResponseBody
    public JSONObject checkSafty(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/safety/check?itv_id="+itv_id,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 共建家园
     * @param itv_id
     * @return
     */
    @RequestMapping("/industry/homeInfo")
    @ResponseBody
    public JSONObject getHomeInfo(String itv_id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/home/info?itv_id="+itv_id,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 公共列表
     * @param itv_id
     * @return
     */
    @RequestMapping("/industry/contentList")
    @ResponseBody
    public JSONObject getcontentList(String itv_id,int page,int size){
        if(page==0){
            page = 1;
        }
        if(size == 0){
            size = 10;
        }

        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/notice/list?itv_id="+itv_id+"&page="+page+"&size="+size,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }

    /**
     * 公共内容
     * @param id
     * @return
     */
    @RequestMapping("/industry/contentInfo")
    @ResponseBody
    public JSONObject getcontentInfo(String itv_id,String id){
        Map<String, String> result = new HashMap<String, String>();
        result = YhzHttpUtils.itfYhzData("https://tyhz.yishengyue.cn/api/stb/notice/info?itv_id="+itv_id+"&id="+id,itv_id,"GET");
        String s = result.get("result");
        JSONObject object = JSONObject.parseObject(s);
        return object;
    }




}
